﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Clouds
   
{
    public class DaylightType
    {
        static public int Night = 4;
        static public int Morning = 1;
        static public int Noon = 2;
        static public int Evening = 3;
    }

    public class Daylight
    {
        public int Current;
        public Daylight()
        {
            this.Current = DaylightType.Morning;
        }
        public Daylight(int T)
        {
            this.Current = T;
        }        
       
    }

    public class Luminary
    {
        private bool shine;
        
        public Luminary()
        {
            this.shine = false;
        }

        public Luminary(bool Shine)
        {
            this.shine = Shine;
        }

        public bool IsShining()
        {
            return shine;
        }
    }

    public class Wind
    {
        private int strength;
        public Wind (int Strength)
        {
            this.strength = Strength;  
        }
        public Wind()
        {
            this.strength = 0;
        }

        public int Strength
        {
            get { return strength; }
            set { strength = value; }
        }
    }

    public class CreatureType
    {
        static public int Puppy = 1;
        static public int Kitten = 2;
        static public int Hedgehog = 3;
        static public int Bearcub = 4;
        static public int Piglet = 5;
        static public int Bat = 6;
        static public int Balloon = 7;
    }

    public class Creature
    {
        public int CreatureType;
        public Creature(int Type)
        {
            this.CreatureType = Type;
        }
       
    }

    public class Magic
    {
        public void CallDaemon(int CreatureType)
        {
            Console.WriteLine("CallDaemon. CreatureType:" + CreatureType);
        }
        public void CallStock(int CreatureType)
        {
            Console.WriteLine("CallStock. CreatureType:" + CreatureType);
        }
       
    }

    class Cloud
    {
        private Daylight daylight = new Daylight();
        private Luminary luminary = new Luminary();
        private Wind wind = new Wind(0);

        private Creature InternalCreate()
        {
            if (daylight.Current == DaylightType.Night)
            {
                return new Creature(CreatureType.Bat);                
            }
            if (daylight.Current == DaylightType.Morning)
            {
                if (luminary.IsShining())
                {
                    if (wind.Strength == 0)
                        return new Creature(CreatureType.Puppy);

                    if ((wind.Strength >= 1) && (wind.Strength <= 4))
                        return new Creature(CreatureType.Hedgehog);

                    if ((wind.Strength >= 5) && (wind.Strength <= 9))
                        return new Creature(CreatureType.Balloon);

                    if (wind.Strength == 10)
                        return new Creature(CreatureType.Kitten);
                }

                if (!luminary.IsShining())
                {
                    if (wind.Strength == 0)
                        return new Creature(CreatureType.Piglet);

                    if ((wind.Strength >= 1) && (wind.Strength <= 4))
                        return new Creature(CreatureType.Kitten);

                    if ((wind.Strength >= 5) && (wind.Strength <= 9))
                        return new Creature(CreatureType.Balloon);

                    if (wind.Strength == 10)
                        return new Creature(CreatureType.Hedgehog);
                }
            }

            if (daylight.Current == DaylightType.Noon)
            {
                if (luminary.IsShining())
                {
                    if (wind.Strength == 0)
                        return new Creature(CreatureType.Kitten);

                    if ((wind.Strength >= 1) && (wind.Strength <= 4))
                        return new Creature(CreatureType.Bearcub);

                    if ((wind.Strength >= 5) && (wind.Strength <= 9))
                        return new Creature(CreatureType.Balloon);

                    if (wind.Strength == 10)
                        return new Creature(CreatureType.Puppy);
                }

                if (!luminary.IsShining())
                {
                    if ((wind.Strength == 0)||(wind.Strength == 10))
                        return new Creature(CreatureType.Bearcub);

                    if ((wind.Strength >= 1) && (wind.Strength <= 9))
                        return new Creature(CreatureType.Puppy);
                }
            }

            if (daylight.Current == DaylightType.Evening)
            {
                if (luminary.IsShining())
                {
                    if ((wind.Strength == 0)||(wind.Strength == 10))
                        return new Creature(CreatureType.Piglet);

                    if ((wind.Strength >= 1) && (wind.Strength <= 4))
                        return new Creature(CreatureType.Puppy);

                    if ((wind.Strength >= 5) && (wind.Strength <= 9))
                        return new Creature(CreatureType.Hedgehog);                     
                }
                if (!luminary.IsShining())
                {
                    if (wind.Strength == 0)
                        return new Creature(CreatureType.Hedgehog);

                    if ((wind.Strength >= 1) && (wind.Strength <= 4))
                        return new Creature(CreatureType.Balloon);

                    if ((wind.Strength >= 5) && (wind.Strength <= 9))
                        return new Creature(CreatureType.Piglet);

                    if (wind.Strength == 10)
                        return new Creature(CreatureType.Kitten);
                }
            }


            // TODO – implement all other creatures

            throw new NotImplementedException();
        }

        public Creature Create()
        {
            Creature creature = InternalCreate();
            Magic magic = new Magic();
            magic.CallDaemon(creature.CreatureType);

            return creature;
        }
    }
}